﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CanDoo.Core.Data;
using CanDoo.Oil.Core.Models;

namespace CanDoo.Oil.Core.ModelConfigurations
{
    /// <summary>
    /// 实体类-数据表映射——系统管理员
    /// </summary>
    public class AdministratorConfiguration : CanDoo.Data.Entity.EntityConfigurationBase<Administrator>
    {
        /// <summary>
        /// 初始化一个<see cref="AdministratorConfiguration"/>类型的新实例
        /// </summary>
        public AdministratorConfiguration()
        {
             ToTable("sys_Administrator");
            this.Property(p => p.UserId).HasColumnName("UserId");
            this.HasRequired(p => p.User).WithMany().HasForeignKey(p => p.UserId).WillCascadeOnDelete(true);

            this.Property(p => p.DepartmentId).HasColumnName("DepartmentId");
            this.HasOptional(p => p.Department).WithMany().HasForeignKey(p => p.DepartmentId).WillCascadeOnDelete(false);
        }
    }
}
